layui.use(['jquery','layer','form'],function(){
    var $ = layui.jquery;
    var layer = layui.layer;
    var form = layui.form;

    //关闭按钮点击事件
    $('#cancel').click(function () {
        var layer = parent.layer;
        layer.close(layer.index);
    });

    $('#confirm').click(function () {
        $('#implementTime').val(setTime());
    });


    form.on('submit(confirm)',function (data) {
        $.ajax({
            url: '/SyCourseRecord/updateProductRecordResult',
            data: data.field,
            type: 'post',
            dataType: 'json',
            success: function (data) {
                var layer = parent.layer;
                layer.close(layer.index);
            }
        });
        return false;
    });
    //获取 年月日 时分秒 星期
    function setTime(){
        var date = new Date();
        var year = date.getFullYear();
        var month = date.getMonth() + 1;
        var today = date.getDate();
        var hour = date.getHours();
        var minute = date.getMinutes();
        var second = date.getSeconds();
        //当小时小于10时进行补零
        var currentTime = zeroFill(year) + '-' + zeroFill(month) + '-' + zeroFill(today) +  ' ' + zeroFill(hour) + ':' + zeroFill(minute) + ':' + zeroFill(second);
        return currentTime;
    }
    //补零
    function zeroFill(time){
        if(time < 10){
            time = '0' + time;
        }
        return time;
    }
})